home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / wheels1.arc / GTSETDIR.PAS < prev    next >
Pascal/Delphi Source File  |  1985-06-28  |  2KB  |  46 lines

  1. {@@@@@@@@@@@ copyright (C) 1984 by Neil J. Rubenking @@@@@@@@@@@@@@@@@@@@@@@@
  2. The purchaser of these procedures and functions may include them in COMPILED
  3. programs freely, but may not sell or give away the source text.
  4.  
  5.      GET and SET the current directory .
  6.      }
  7.  
  8. program GetSetDirectory;
  9. {$I errmessg.lib}  {<-- to interpret any error messages}
  10. {$I filename.typ}
  11. {$I regpack.typ}   {<-- the "type" for REGISTERS variables for MSDOS calls}
  12. {$I getsetdd.lib}  {<-- you might ask to set the drive, too}
  13. {$I gtsetdir.lib}  {<-- THE MAIN ATTRACTION}
  14. var
  15.   the_directory : filename_type;
  16.   drive         : char;
  17.   error_return  : byte;
  18.  
  19. begin
  20.   GetSetDrive('G',drive);
  21.   GetSetDirectory('G',drive,the_directory,error_return);
  22.   WriteLn('Current directory is ',the_directory);
  23.   Write('Set to what? ');
  24.   ReadLn(the_directory);
  25.  
  26.   if pos(':',the_directory) <> 0 then            {if the requested new      }
  27.     begin                                        {directory contains a drive}
  28.       if upCase(the_directory[1]) <> drive then  {letter, see if it's the   }
  29.         begin                                    {same as the current drive.}
  30.           drive := upCase(the_directory[1]);     {If not, change the current}
  31.           GetSetDrive('S',drive);                {drive.                    }
  32.           WriteLn('Drive changed to ',drive);
  33.         end;
  34.       delete(the_directory,1,2);
  35.     end;
  36.   if length(the_directory) > 0 then
  37.      GetSetDirectory('S',drive,the_directory,error_return);
  38.   if error_return <> 0 then
  39.     WriteLn(message(error_return))
  40.   else
  41.     begin
  42.       the_directory := drive + ':' + the_directory;
  43.       writeLn(the_directory,' is the current directory.');
  44.     end;
  45. end.
  46.